<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1">
		<!-- Google Chrome Frame也可以让IE用上Chrome的引擎: -->
		<meta name="renderer" content="webkit">
		<!--国产浏览器高速模式-->
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title>电力通信后台</title>

		<!-- 公共样式 开始 -->
		<link rel="stylesheet" type="text/css" href="../../css/base.css">
		<link rel="stylesheet" type="text/css" href="../../css/iconfont.css">
		<script type="text/javascript" src="../../framework/jquery-1.11.3.min.js"></script>
		<link rel="stylesheet" type="text/css" href="../../layui/css/layui.css">
		<script type="text/javascript" src="../../layui/layui.js"></script>
		<!-- 滚动条插件 -->
		<link rel="stylesheet" type="text/css" href="../../css/jquery.mCustomScrollbar.css">
		<script src="../../framework/jquery-ui-1.10.4.min.js"></script>
		<script src="../../framework/jquery.mousewheel.min.js"></script>
		<script src="../../framework/jquery.mCustomScrollbar.min.js"></script>
		<script src="../../framework/cframe.js"></script><!-- 仅供所有子页面使用 -->
		<!-- 公共样式 结束 -->
		<script type="text/javascript" src="../../framework/frame.js" ></script>

		<style>

			.cBody{
				width: 100%;
				height:100% !important;;
			}



		</style>

	</head>

	<body>
		<div class="cBody" style="width: 100%;height:100% !important;">
			<form id="addForm" class="layui-form" action="" >
				<div class="layui-form-item">
					<label class="layui-form-label">登录名</label>
					<div class="layui-input-inline shortInput">
						<input disabled type="text" id="managerid" name="managerid" required lay-verify="managerid" placeholder="请输入登录名" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">姓名</label>
					<div class="layui-input-inline shortInput">
						<input type="text" id="managername" name="managername" required lay-verify="managername" placeholder="请输入姓名" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">登录密码</label>
					<div class="layui-input-inline shortInput">
						<input type="password" id="manpassword" name="manpassword" required lay-verify="manpassword" placeholder="请设置登录密码" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">性别</label>
					<div class="layui-input-block">
						<input type="radio" style="margin-top: 10px;" name="sex" value="1" title="男" checked>
						<input type="radio" name="sex" value="2" title="女">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">所属部门</label>
					<div class="layui-input-block ">
						<select class="layui-input-block" style="margin-left: 0px;" name="mandepartId" id="dept" lay-verify="required">
						</select>
					</div>

				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">职位</label>
					<div class="layui-input-block ">
						<select class="layui-input-block" style="margin-left: 0px;" name="manposition" id="position" lay-verify="required">
						</select>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">联系电话</label>
					<div class="layui-input-inline shortInput">
						<input type="text" id="mantel" name="mantel" required lay-verify="required|phone" placeholder="例：13000000000" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item layui-form-text">
					<label class="layui-form-label">家庭住址</label>
					<div class="layui-input-block ">
						<input type="text" id="manaddress" name="manaddress" lay-verify="address" placeholder="请再次输入家庭住址" autocomplete="off" class="layui-input">
					</div>
				</div>

				<div class="layui-form-item">
					<div class="layui-input-block">
						<button class="layui-btn" id="btn" lay-submit lay-filter="submitBut">立即提交</button>
						<button type="reset" class="layui-btn layui-btn-primary">重置</button>
					</div>
				</div>
			</form>


			<script>
				$(document).ready(function(){
					getDept()
					getPosition()
				});
				layui.use(['upload','form'], function() {
					var form = layui.form;
					var upload = layui.upload;
					var layer = layui.layer;
					//监听提交
					//解决了layui.open弹窗从内部关闭这个弹窗的问题
					form.on('submit(submitBut)', function(data) {
						var updateFrame = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
						parent.layer.close(updateFrame);  //再改变当前层的标题
					});
					form.verify({
						//数组的两个值分别代表：[正则匹配、匹配不符时的提示文字]
					  	ZHCheck: [
						    /^[\u0391-\uFFE5]+$/
						    ,'只允许输入中文'
					  	]
					});
				});
				function  getDept() {
					$.ajax({
						url: 'http://localhost:8888/dept/list',
						dataType: 'json',
						type: 'get',
						success: function (data) {
							console.log(data)
							$.each(data.detail, function (index, item) {
								$('#dept').append(new Option(item.name, item.id));// 下拉菜单里添加元素
							});
							layui.form.render("select");
						}
					})
				}
				function  getPosition() {
					$.ajax({
						url: 'http://localhost:8888/position/list',
						dataType: 'json',
						type: 'get',
						success: function (data) {
							console.log(data)
							$.each(data.detail, function (index, item) {
								$('#position').append(new Option(item.name, item.id));// 下拉菜单里添加元素
							});
							layui.form.render("select");
						}
					})
				}
			</script>

		</div>
	</body>

</html>
